#ifndef __MOTOR_H
#define __MOTOR_H

#define Motor1 11
#define Motor2 22
#define Motor3 33
#define Motor4 44

#define Motor_TIM TIM1

#define FORWARD 1
#define REVERSE -1
#define STOP 0

#define Motor1_IN1_GPIO GPIOE
#define Motor1_IN2_GPIO GPIOE
#define Motor1_PWM_GPIO GPIOE
#define Motor1_IN1_PIN GPIO_Pin_7
#define Motor1_IN2_PIN GPIO_Pin_8
#define Motor1_PWM_PIN GPIO_Pin_9

#define Motor2_IN1_GPIO GPIOE
#define Motor2_IN2_GPIO GPIOE
#define Motor2_PWM_GPIO GPIOE
#define Motor2_IN1_PIN GPIO_Pin_10
#define Motor2_IN2_PIN GPIO_Pin_12
#define Motor2_PWM_PIN GPIO_Pin_11

#define Motor3_IN1_GPIO GPIOE
#define Motor3_IN2_GPIO GPIOD
#define Motor3_PWM_GPIO GPIOE
#define Motor3_IN1_PIN GPIO_Pin_15
#define Motor3_IN2_PIN GPIO_Pin_10
#define Motor3_PWM_PIN GPIO_Pin_13

#define Motor4_IN1_GPIO GPIOD
#define Motor4_IN2_GPIO GPIOB
#define Motor4_PWM_GPIO GPIOE
#define Motor4_IN1_PIN GPIO_Pin_11
#define Motor4_IN2_PIN GPIO_Pin_15
#define Motor4_PWM_PIN GPIO_Pin_14

#define Motor1_RA_GPIO GPIOC
#define Motor1_RB_GPIO GPIOC
#define Motor1_RA_PIN GPIO_Pin_0
#define Motor1_RB_PIN GPIO_Pin_1

#define Motor2_RA_GPIO GPIOC
#define Motor2_RB_GPIO GPIOC
#define Motor2_RA_PIN GPIO_Pin_2
#define Motor2_RB_PIN GPIO_Pin_3

#define Motor3_RA_GPIO GPIOD
#define Motor3_RB_GPIO GPIOD
#define Motor3_RA_PIN GPIO_Pin_0
#define Motor3_RB_PIN GPIO_Pin_1

#define Motor4_RA_GPIO GPIOD
#define Motor4_RB_GPIO GPIOD
#define Motor4_RA_PIN GPIO_Pin_4
#define Motor4_RB_PIN GPIO_Pin_7


struct Motor_State
{
	int8_t derection;//1为正转，-1为反转，0为停止
	uint16_t speed;//转速
};

static struct Motor_State motor_1,motor_2,motor_3,motor_4;


void Motor_Init(void);
struct Motor_State Get_Motor_state(uint8_t ID);
void Motor_SetSpeed(uint8_t ID,int16_t Speed);

#endif
